package dao

import (
	"shorten/internal/model"
	"shorten/pkg/util"
	"strings"
)

// 根据用户名来获取用户id
func FindUserId(userName string, column []string) *model.User {
	user := model.User{}
	err := DB().Model(&model.User{}).Select(strings.Join(column, ",")).Where("user_name=?", userName).Limit(1).Find(&user).Error
	util.CheckErr(err)
	return &user
}

func AddUser(u *model.User) error {
	return DB().Create(&u).Error
}
